package com.igeekhome.controller.api;

import com.igeekhome.pojo.DNetwork;
import com.igeekhome.service.IScanService;
import com.igeekhome.service.IStaffService;
import com.igeekhome.util.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 汪璇
 */
@RestController
@RequestMapping("/api/scan")
public class ScanControllerApi {

    @Autowired
    private IScanService scanService;
    
    @Autowired
    private IStaffService staffService;
    
    @Value("${SCANER_CLERK}")
    private Integer SCANER_CLERK;
    
    //收件扫描
    @RequestMapping("/receiveScan")
    public ResultBean receiveScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.receiveScanList(network,page,limit);
    }
    
    //收件扫描操作
    @RequestMapping("/receiveScanOp")
    public ResultBean receiveScanOp(Integer id){
        return scanService.receiveScan(id);
    }
    
    //收件交单扫描
    @RequestMapping("/receiptDocScan")
    public ResultBean receiptDocScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.receiptDocScanList(network,page,limit);
    }
    
    //收件交单返回此站点扫描员dtree数据
    @RequestMapping("/staffList")
    public ResultBean staffList(HttpSession session){
        //获取当前session中网点编号
        DNetwork network = (DNetwork)session.getAttribute("network");
    
        //根据网点查询配送员
        ResultBean resultBean = staffService.selectByNetworkId(network,SCANER_CLERK);
        return resultBean;
    }
    
    /**
     * @Description 扫描分配操作
     * @Param []
     * @Return com.igeekhome.util.ResultBean
     **/
    @RequestMapping("/distScaner")
    public ResultBean distScaner(Integer staffId,Integer[] ordersId){
        
        return scanService.ditScaner(staffId,ordersId);
    }
    
    //装袋扫描
    @RequestMapping("/bagScan")
    public ResultBean bagScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.bagScanList(network,page,limit);
    }
    
    //装袋扫描操作
    @RequestMapping("/bagScanOp")
    public ResultBean bagScanOp(Integer id){
        return scanService.receiveScan(id);
    }
    
    //问题件扫描
    @RequestMapping("/problemScan")
    public ResultBean problemScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.problemScanList(network,page,limit);
    }
    
    //问题件扫描操作
    @RequestMapping("/problemScanOp")
    public ResultBean problemScanOp(Integer id){
        return scanService.problemScan(id);
    }
    
    //问题件扫描操作
    @RequestMapping("/problemScanHandle")
    public ResultBean problemScanHandle(Integer id){
        return scanService.problemScan(id);
    }
    
    //发件扫描
    @RequestMapping("/sendScan")
    public ResultBean sendScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.sendScanList(network,page,limit);
    }
    
    
    //发件扫描操作
    @RequestMapping("/sendScanOp")
    public ResultBean sendScanOp(Integer networkId,Integer[] scanIds){
        return scanService.sendScan(scanIds,networkId);
    }
    
    /**
    * @Description设置下一站
    * @Param []
    * @Return com.igeekhome.util.ResultBean
    **/
    @RequestMapping("/networkList")
    public ResultBean networkList(){
        return scanService.networkList();
    }
    
    
    //到件扫描
    @RequestMapping("/arriveScan")
    public ResultBean arriveScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.arriveScanList(network,page,limit);
    }
    
    //到件扫描操作
    @RequestMapping("/arriveScanOp")
    public ResultBean arriveScanOp(Integer id){
        return scanService.arriveScan(id);
    }
    
    //派件扫描
    @RequestMapping("/distributeScan")
    public ResultBean distributeScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.distributeScanList(network,page,limit);
    }
    
    //派件扫描操作
    @RequestMapping("/distributeScanOp")
    public ResultBean distributeScanOp(Integer id){
        return scanService.distributeScan(id);
    }
    
    //派件交单扫描
    @RequestMapping("/dispatchDocScan")
    public ResultBean dispatchDocScan(HttpSession session,Integer page,Integer limit){
        DNetwork network = (DNetwork)session.getAttribute("network");
        return scanService.dispatchDocScanList(network,page,limit);
    }
    
    //派件交单操作
    @RequestMapping("/dispatchDocScanOp")
    public ResultBean dispatchDocScanOp(Integer id){
        return scanService.dispatchDocScan(id);
    }
    //到件扫描 到件扫描操作 //派件扫描 派件扫描操作 //派件交单扫描//派件交单扫描操作
    
    }

    
